<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
<html>
	<head>
		<title>产品列表</title>
		<html:base />
		<meta http-EQUIV="Content-Type" content="text/html; charset=utf-8">
		<META HTTP-EQUIV="Cache-Control" CONTENT="max-age=0">
		<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
		<meta http-EQUIV="expires" content="0">
		<META HTTP-EQUIV="Expires" CONTENT="Tue, 01 Jan 1980 1:00:00 GMT">
		<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
		<link href="<%=path%>/css/hcss.css" rel="stylesheet" type="text/css">
		<link href="<%=path%>/css/style.css" rel="stylesheet" type="text/css">
		<script language="JavaScript" type="text/JavaScript"
			src="<%=path%>/JS/checkBox.js"></script>
		<script language=JavaScript src="/JS/xmlhttp.js"></script>
		<script language="javascript">
	
function save(id){
	document.location.href="<%=path%>/admin/productClassAction.do?method=saveProductClass&id="+id;
}
function uploadImg(id,name){
	document.location.href="<%=path%>/admin/productClassAction.do?method=uploadImg&id="+id;
}
function edit(id){
	document.location.href="<%=path%>/admin/productClassAction.do?method=editProductClass&id="+id;
}	  
	  	
function del(id){
	if(confirm("\n                     确定要删除此大类吗？\n\n\n删除此大类同时将删除所包含的小类，并且该类下的产品信息也将删除,不能恢复！")){
		document.location.href="<%=path%>/admin/productClassAction.do?method=deleteProductClass&id="+id;
	}
}

function getChildType2(typeid){
	var tree = document.getElementById('tree_'+typeid);
	var child = document.getElementById('tr_'+typeid);
	if(tree.src.indexOf('/images/tree_folder+.gif')>0){
		if(child && typeid!=""){
			tree.src='/images/tree_folder-.gif';
			send_request(function(value){child.innerHTML=value},"/admin/productClassAction.do?method=childType2&id="+ typeid+"&"+Math.random(), true);
		}
	}else{
	tree.src='/images/tree_folder+.gif';
	child.innerHTML= "";
	}
}
function getChildType3(typeid){
	var tree = document.getElementById('tree_'+typeid);
	var child = document.getElementById('tr_'+typeid);
	if(tree.src.indexOf('/images/tree_folder+.gif')>0){
		if(child && typeid!=""){
			tree.src='/images/tree_folder-.gif';
			send_request(function(value){child.innerHTML=value},"/admin/productClassAction.do?method=childType3&id="+ typeid+"&"+Math.random(), true);
		}
	}else{
	tree.src='/images/tree_folder+.gif';
	child.innerHTML= "";
	}
}
function getChildType4(typeid){
	var tree = document.getElementById('tree_'+typeid);
	var child = document.getElementById('tr_'+typeid);
	if(tree.src.indexOf('/images/tree_folder+.gif')>0){
		if(child && typeid!=""){
			tree.src='/images/tree_folder-.gif';
			send_request(function(value){child.innerHTML=value},"/admin/productClassAction.do?method=childType4&id="+ typeid+"&"+Math.random(), true);
		}
	}else{
	tree.src='/images/tree_folder+.gif';
	child.innerHTML= "";
	}
}
</script>

	</head>

	<body>
		<!-- 分页用 -->

			<table width="90%" border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td width="30">
					</td>
					<td width="100%" valign="top" align="center">
						<table width="100%" height="100%" border="0" cellspacing="0"
							cellpadding="0" align="center" class="tabletextwhite">
							<tr>
								<td class="tdtitle" width="100%" height="27">
									产品类别设置
								</td>
							</tr>
							<tr>
								<td height="5px">
								</td>
							</tr>
						</table>
						<table width="100%" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td align="center">
									<font color="red">『注意：为了避免数据流失，删除类别时检查是该类的产品数据，建议先在产品类表中删除该类的产品数据』
									</font>
								</td>
							</tr>
							<tr>
								<td>
									<div align="right">
										<input name="role" type="button" class="cmd"
											onclick="save('')" value="添加一级类">
									</div>
								</td>
							</tr>
						</table>
						<br>
						<table width="100%" border="0" cellpadding="0" cellspacing="1">
							<tr align="center">
								<th scope="col">
									栏目名称
								</th>
								<th scope="col">
									排序 
								</th>
								<th scope="col">
									操作选项
								</th>
							</tr>

								<#list listItem as type>
								<tr onMouseOver="this.style.backgroundColor='#BFDFFF'"
									onmouseout="this.style.backgroundColor=''">
									<td width="30%" align="left"
										onclick="getChildType2('${type.id}')">
										<img
											id="tree_${type.id}"
											src="/images/tree_folder+.gif">
										${type.typename}
									</td>
									<td align="center" width="30%">
										${type.taxis}
									</td>
									<td width="30%" align="center">
										<u onclick="save(${type.id})"
											style="cursor: pointer;"> 添加二级类 </u> |
										<u onclick="edit(${type.id})"
											style="cursor: pointer;"> 修改 </u>

										<u onclick="del(${type.id})" style="cursor: pointer;">删除
											</u>
									</td>
								</tr>
								<tr>
									<td id="tr_${type.id}"
										colspan="3">
									</td>
								</tr>
							</#list>
						</table>
					</td>
				</tr>
			</table>
		<center>
			<font color="red"> </font>
		</center>
	</body>
</html>
